/*
 * @FilePath     : /layui/routes/form-selects.js
 * @Description  : formSelects-v4
 * @Date         : 2025-02-20 16:20
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-02-21 09:22
 */
const express = require('express')

const router = express.Router()

// 1）当前模块测试路由
router.get('/', (req, res) => {
  res.send('下拉选路由器')
})

// 2）远程搜索1
router.get('/search1', (req, res) => {
  res.json({
    code: 0,
    msg: 'success',
    data: [
      { name: '北京', value: 1, selected: '', disabled: '' },
      { name: '上海', value: 2, selected: '', disabled: '' },
      { name: '广州', value: 3, selected: 'selected', disabled: '' },
      { name: '深圳', value: 4, selected: '', disabled: 'disabled' },
      { name: '天津', value: 5, selected: '', disabled: '' },
    ],
  })
})

// 3）远程搜索2
router.get('/search2', (req, res) => {
  res.json({
    code: 0,
    msg: 'success',
    data: [
      { name: '分组-1', type: 'optgroup' },
      { name: '北京', value: 1, selected: '', disabled: '' },
      { name: '上海', value: 2, selected: '', disabled: '' },
      { name: '分组-2', type: 'optgroup' },
      { name: '广州', value: 3, selected: 'selected', disabled: '' },
      { name: '深圳', value: 4, selected: '', disabled: 'disabled' },
      { name: '天津', value: 5, selected: '', disabled: '' },
    ],
  })
})

// 4）级联数据1
router.get('/area-data-list', (req, res) => {
  res.json({
    code: 0,
    msg: 'vant 组件提供的级联地址数据',
    data: [
      // 一级节点 - 1
      {
        name: '北京xx',
        value: 1,
        children: [
          // 二级节点
          {
            name: '北京1',
            value: 12,
            children: [
              // 三级节点
              {
                name: '朝阳区',
                value: 13,
                children: [
                  {
                    name: '东胡同',
                    value: 131,
                  },
                  {
                    name: '南胡同',
                    value: 132,
                  },
                  {
                    name: '西胡同',
                    value: 133,
                  },
                  {
                    name: '北胡同',
                    value: 134,
                  },
                ],
              },
            ],
          },
        ],
      },
      // 一级节点 - 2
      {
        name: '合肥',
        value: 2,
        children: [
          // 二级节点
          {
            name: '合肥1',
            value: 21,
            children: [
              // 三级节点
              {
                name: '蜀山区区',
                value: 211,
                children: [
                  {
                    name: '兴园街道',
                    value: 2111,
                  },
                  {
                    name: '南七街道',
                    value: 2112,
                  },
                  {
                    name: '南岗街道',
                    value: 2113,
                  },
                  {
                    name: '笔架山街道',
                    value: 2114,
                  },
                ],
              },
            ],
          },
        ],
      },
    ],
  })
})

module.exports = router
